<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.omg.org/spec/BPMN/20100524/MODEL">

<head>
	<title>琰通后台管理系统_V1.0.0</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="ctx" th:content="${#httpServletRequest.getContextPath()}"/>
    <meta name="keywords" content="琰通后台管理系统_V1.0.0">
    <meta name="description" content="琰通后台管理系统_V1.0.0">
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css" rel="stylesheet">
    <link href="/css/login.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>

</head>

<body class="signin">
<div class="signinpanel">
    <div class="row">
        <div style="text-align: center;margin: auto;width: 85%;">
            <div class="signin-info">
                <div class="m-b">
                    <h1>
                         <strong>欢迎使用 琰通后台管理系统</strong>
                    </h1>
                </div>

            </div>
            <form id="signupForm">
                <h3 class="text-center">用户登录</h3>
                <div class="form-group">
                    <div class="col-sm-12">
                        <input type="text" name="username" id="username" class="form-control uname" placeholder="请输入用户名"/>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <input type="password" name="password" id="password" class="form-control pword m-b" placeholder="请输入密码"/>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-8">
                        <input type="text" name="verifyCode" id="verifyCode" class="form-control pword uname" placeholder="请输入验证码" style="margin-top: 0px"/>
                    </div>
                    <div>
                        <span>
                             <img alt="验证码" onclick = "this.src='/getKaptchaImage?d='+new Date()*1" src="/getKaptchaImage" />
                        </span>
                    </div>
                </div>
                <button class="btn btn-login text-center" style="text-align: center;margin-top: 0px">登录</button>
            </form>
        </div>
    </div>
    <div class="signup-footer">
        <div class="pull-right">&copy; 2018 All Rights Reserved. NJ</div>
    </div>
</div>
<script th:inline="javascript"> var ctx = [[@{/}]] ; </script>
<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4" ></script>
<script src="/js/bootstrap.min.js?v=3.3.6" ></script>
<script src="/js/encrypt.min.js"></script>
<!-- 自定义js -->
<script src="/js/content.js?v=1.0.0" ></script>
<!-- jQuery Validation plugin javascript-->
<script src="/js/plugins/validate/jquery.validate.min.js" ></script>
<script src="/js/plugins/validate/messages_zh.min.js" ></script>
<script src="/js/plugins/layer/layer.min.js" ></script>
<script type="text/javascript">
    $(document).ready(function () {
        console.log(ctx);
        validateRule();
    });

    $.validator.setDefaults({
        submitHandler: function () {
            login();
        }
    });

    function login() {
        var password = encrypt($.trim($('#password').val()))
        $.ajax({
            type: "POST",
            url: ctx+"login",
            data: {
                username:$.trim($('#username').val()),
                password: password,
                verifyCode: $.trim($('#verifyCode').val())
            },
            success: function (r) {
                if (r.code == 0) {
                    parent.location.href = '/index';
                } else {
                    layer.msg(r.msg);
                }
            }
        });
    }

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#signupForm").validate({
            rules: {
                username: {
                    required: true
                },
                password: {
                    required: true
                },
                verifyCode: {
                    required: true
                },
            },
            messages: {
                username: {
                    required: icon + "请输入您的用户名"
                },
                password: {
                    required: icon + "请输入您的密码"
                },
                verifyCode: {
                    required: icon + "验证码不能为空"
                },
            }
        })
    }
</script>
</body>
</html>
